﻿using Service.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Model.Table
{
    /// <summary>
    /// TableInfo 的摘要说明
    /// </summary>
    public class TableInfo
    {
        /// Excel表上传配置
        /// <summary>
        /// Excel表上传配置
        /// </summary>
        public static List<TableConfig> GetTableConfig
        {
            get
            {
                List<TableConfig> list = new List<TableConfig>();
                list.Add(new TableConfig() { RedisHashKey = TableBuilding.Tablename, Key = "id", Path = "table\\Building.xls", Sheet = 0, SheetName = "Building" });
                list.Add(new TableConfig() { RedisHashKey = TableBuildingLevelShipyard.Tablename, Key = "level", Path = "table\\Building.xls", Sheet = 1, SheetName = "ShipyardLevel" });
                list.Add(new TableConfig() { RedisHashKey = TableBuildingLevelPub.Tablename, Key = "level", Path = "table\\Building.xls", Sheet = 2, SheetName = "PubLevel" });
                list.Add(new TableConfig() { RedisHashKey = TableBuildingLevelWareHouse.Tablename, Key = "level", Path = "table\\Building.xls", Sheet = 3, SheetName = "WareHouseLevel" });
                list.Add(new TableConfig() { RedisHashKey = TableBuildingLevel.Tablename, Key = "level", Path = "table\\Building.xls", Sheet = 4, SheetName = "BuildingLevel" });
                list.Add(new TableConfig() { RedisHashKey = TableBuildingLevelMain.Tablename, Key = "level", Path = "table\\Building.xls", Sheet = 5, SheetName = "BuildingLevelMain" });
                list.Add(new TableConfig() { RedisHashKey = TableBuildingLevelHouse.Tablename, Key = "level", Path = "table\\Building.xls", Sheet = 5, SheetName = "HouseLevel" });
                list.Add(new TableConfig() { RedisHashKey = TableBuildingLevelTextileFactory.Tablename, Key = "level", Path = "table\\Building.xls", Sheet = 5, SheetName = "TextileFactoryLevel" });
                list.Add(new TableConfig() { RedisHashKey = TableBuildingLevelWoodRoom.Tablename, Key = "level", Path = "table\\Building.xls", Sheet = 5, SheetName = "WoodRoomLevel" });
                list.Add(new TableConfig() { RedisHashKey = "Table_Captain", Key = "id", Path = "table\\Captain.xls", Sheet = 0, SheetName = "Captain" });
                list.Add(new TableConfig() { RedisHashKey = "Table_City", Key = "Id", Path = "table\\City.xls", Sheet = 0, SheetName = "City" });
                list.Add(new TableConfig() { RedisHashKey = "Table_Commodity", Key = "id", Path = "table\\Commodity.xls", Sheet = 0, SheetName = "Commodity" });
                list.Add(new TableConfig() { RedisHashKey = "Table_CommonProperty", Key = "property_name", Path = "table\\CommonProperty.xls", Sheet = 0, SheetName = "CommonProperty" });
                //list.Add(new TableConfig() { RedisHashKey = "Table_Dialog", Path = "table\\Dialog.xls", Sheet = 0, SheetName = "Dialog" });
                list.Add(new TableConfig() { RedisHashKey = "Table_LockZone", Key = "id", Path = "table\\LockZone.xls", Sheet = 0, SheetName = "LockZone" });
                //list.Add(new TableConfig() { RedisHashKey = "Table_Notebook", Key = "id", Path = "table\\Notebook.xls", Sheet = 0, SheetName = "Notebook" });
                list.Add(new TableConfig() { RedisHashKey = "Table_PlayerLevel", Key = "level", Path = "table\\Player.xls", Sheet = 0, SheetName = "PlayerLevel" });
                list.Add(new TableConfig() { RedisHashKey = "Table_Quest", Key = "id", Path = "table\\Quest.xls", Sheet = 0, SheetName = "Quest" });
                list.Add(new TableConfig() { RedisHashKey = "Table_SailorSkill", Key = "id", Path = "table\\SailorSkill.xls", Sheet = 0, SheetName = "SailorSkill" });
                list.Add(new TableConfig() { RedisHashKey = "Table_sea_point", Key = "id", Path = "table\\SeaMap.xls", Sheet = 0, SheetName = "sea_point" });
                list.Add(new TableConfig() { RedisHashKey = "Table_sea_connect", Key = "id", Path = "table\\SeaMap.xls", Sheet = 1, SheetName = "sea_connect" });
                list.Add(new TableConfig() { RedisHashKey = "Table_sea_mask", Key = "id", Path = "table\\SeaMap.xls", Sheet = 2, SheetName = "sea_mask" });
                list.Add(new TableConfig() { RedisHashKey = "Table_sea_wind", Key = "id", Path = "table\\SeaMap.xls", Sheet = 5, SheetName = "sea_wind" });
                list.Add(new TableConfig() { RedisHashKey = "Table_Ship", Key = "id", Path = "table\\Ship.xls", Sheet = 0, SheetName = "Ship" });
                //list.Add(new TableConfig() { RedisHashKey = "Table_ship_lv_up", Key = "id", Path = "table\\Ship.xls", Sheet = 1, SheetName = "ship_lv_up" });
                list.Add(new TableConfig() { RedisHashKey = "Table_Surname", Key = "id", Path = "table\\RandomName.xls", Sheet = 0, SheetName = "Surname" });
                list.Add(new TableConfig() { RedisHashKey = "Table_GivennameMs", Key = "id", Path = "table\\RandomName.xls", Sheet = 0, SheetName = "GivennameMs" });
                list.Add(new TableConfig() { RedisHashKey = "Table_GivennameFs", Key = "id", Path = "table\\RandomName.xls", Sheet = 0, SheetName = "GivennameFs" });
                list.Add(new TableConfig() { RedisHashKey = "Table_GivennameM", Key = "id", Path = "table\\RandomName.xls", Sheet = 0, SheetName = "GivennameM" });
                list.Add(new TableConfig() { RedisHashKey = "Table_GivennameF", Key = "id", Path = "table\\RandomName.xls", Sheet = 0, SheetName = "GivennameF" });
                list.Add(new TableConfig() { RedisHashKey = "Table_GameEvent", Key = "id", Path = "table\\Event.xls", Sheet = 0, SheetName = "Event" });
                list.Add(new TableConfig() { RedisHashKey = "Table_CollectPoint", Key = "id", Path = "table\\CollectPoint.xls", Sheet = 1, SheetName = "CollectPoint" });
                list.Add(new TableConfig() { RedisHashKey = "Table_CityTechnical", Key = "Id", Path = "table\\CityTechnical.xls", Sheet = 0, SheetName = "CityTechnical" });
                list.Add(new TableConfig() { RedisHashKey = "Table_Level", Key = "id", Path = "table\\Level.xls", Sheet = 0, SheetName = "Level" });
                list.Add(new TableConfig() { RedisHashKey = "Table_OrderQuestBase", Key = "id", Path = "table\\OrderQuestBase.xls", Sheet = 0, SheetName = "OrderQuestBase" });

                return list;
            }
        }

        /// 根据配置表中的某一个关联外键，存储数据
        /// <summary>
        /// 根据配置表中的某一个关联外键，存储数据
        /// </summary>
        public static List<TableConfig> GetTableConfigOrderKey
        {
            get
            {
                List<TableConfig> list = new List<TableConfig>();
                list.Add(new TableConfig() { RedisHashKey = "Table_ship_lv_up", Key = "ship_id", Path = "table\\Ship.xls", Sheet = 1, SheetName = "ship_lv_up" });

                return list;
            }
        }

        /// 查询业务模块，需要在这边配置好相关调用接口
        /// <summary>
        /// 查询业务模块，需要在这边配置好相关调用接口
        /// </summary>
        /// <param name="command_id"></param>
        /// <returns></returns>
        public static TableBase GetTableInfo(string name)
        {
            TableBase table = null;
            switch (name)
            {
                case "Building":
                    table = new TableBuilding();
                    break;
                case "BuildingLevel":
                    table = new TableBuildingLevel();
                    break;
                case "BuildingLevelMain":
                    table = new TableBuildingLevelMain();
                    break;
                case "Captain":
                    table = new TableCaptain();
                    break;
                case "City":
                    table = new TableCity();
                    break;
                case "Commodity":
                    table = new TableCommodity();
                    break;
                case "CommonProperty":
                    table = new TableCommonProperty();
                    break;
                case "LockZone":
                    table = new TableLockZone();
                    break;
                case "PlayerLevel":
                    table = new TablePlayerLevel();
                    break;
                case "Quest":
                    table = new TableQuest();
                    break;
                case "SailorSkill":
                    table = new TableSailorSkill();
                    break;
                case "sea_point":
                    table = new TableSeaPoint();
                    break;
                case "sea_connect":
                    table = new TableSeaConnect();
                    break;
                case "sea_mask":
                    table = new TableSeaMask();
                    break;
                case "sea_wind":
                    table = new TableSeaWind();
                    break;
                case "Ship":
                    table = new TableSeaShip();
                    break;
                case "ship_lv_up":
                    table = new TableShipLvUp();
                    break;
                case "Surname":
                    table = new TableSurname();
                    break;
                case "GivennameMs":
                    table = new TableGivennameMs();
                    break;
                case "GivennameFs":
                    table = new TableGivennameFs();
                    break;
                case "GivennameM":
                    table = new TableGivennameM();
                    break;
                case "GivennameF":
                    table = new TableGivennameF();
                    break;
                case "Event":
                    table = new TableGameEvent();
                    break;
                case "CityTechnical":
                    table = new TableCityTechnical();
                    break;
                case "Level":
                    table = new TableLevel();
                    break;
                case "OrderQuestBase":
                    table = new TableOrderQuestBase();
                    break;
                default: break;
            }
            return table;
        }

    }

    #region Model

    /// Excel配置类
    /// <summary>
    /// Excel配置类
    /// </summary>
    public class TableConfig
    {
        /// redis数据库对应hashKey
        /// <summary>
        /// redis数据库对应hashKey
        /// </summary>
        public string RedisHashKey { get; set; }

        /// hash列表中的key
        /// <summary>
        /// hash列表中的key
        /// </summary>
        public string Key { get; set; }

        /// Excel文件路径
        /// <summary>
        /// Excel文件路径
        /// </summary>
        public string Path { get; set; }

        /// sheet下标
        /// <summary>
        /// sheet下标
        /// </summary>
        public int Sheet { get; set; }

        /// sheet名称
        /// <summary>
        /// sheet名称
        /// </summary>
        public string SheetName { get; set; }
    }

    #endregion Model
}